﻿using DapperExtensions;
using WMLogistics.Model;
using WMLogistics_Dao;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Logistics.Model;

namespace WMLogistics.Service
{
    public class WMReportBidService
    {
        private WMReportBidDao dao = new WMReportBidDao();
        private WMBidLoadDao biddao = new WMBidLoadDao();
        private WMBidBaseService baseSevice = new WMBidBaseService();
        public PageData<wuliu_wm_report_base> GetReportList(IPredicate predicate, int pageIndex, int pageSize)
        {
            return dao.GetReportList(predicate,pageIndex,pageSize);
        }

        /// <summary>
        /// 操作未结变成已结
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        public int OperatReportList(string[] list)
        {
            
            foreach(var str in list)
            {
                var mod = dao.Get(Convert.ToInt32(str));
                wuliu_wm_report_base reportmod=new wuliu_wm_report_base();
                reportmod.report_id = mod.report_id;
                reportmod.state = 100;
                int num = dao.Update(reportmod);
                wuliu_wm_bid_base bid = new wuliu_wm_bid_base();
                bid.bid_id = (int)reportmod.bid_id;
                bid.state = 150;
                baseSevice.BidBaseUpdate(bid);
                //if(mod.wuliu_id!=null)
                //{
                //    var enty = biddao.GetBidLoadList((int)mod.wuliu_id, mod.company_no);
                //    if(enty!=null)
                //    {
                //        reportmod.report_id = mod.report_id;
                //        reportmod.wuliu_no = enty.wuliu_no;
                //        reportmod.wuliu_name = enty.wuliu_name;
                //        reportmod.company_no = enty.company_no;
                //        reportmod.company_name = enty.company_name;
                //        reportmod.order_num = enty.order_num;
                //        reportmod.receipt_time = enty.receipt_time;
                //        reportmod.end_city_id = enty.end_city_id;
                //        reportmod.end_city_id_x = enty.end_city_id_x;
                //        reportmod.end_city_name = enty.end_city_name;
                //        int num = dao.Update(reportmod);
                //    }
                    
                //}
                
            }
            return list.Count();
        }
    }
}
